<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
<script>
	function extendx(Child, Parent) {
		var F = function() {};
		F.prototype = Parent.prototype;
		Child.prototype = new F();
		Child.prototype.constructor = Child;
		Child.uber = Parent.prototype;
	}

	// 通过应用上面的函数（读者也可以自行在定义一个），我们既可以是代码保持简洁，又能将其重用在构建继承关系的任务中。这种方式让我们能通过以下简单的调用来实现继承。

	// 让我们来看一个完整的例子
	function Shape() {};
	Shape.prototype.name = 'Shape';
	Shape.prototype.toString = function() {
		return this.constructor.uber
			? this.constructor.uber.toString() +', '+this.name
			: this.name;
	}

	function TwoDShape() {};
	extendx(TwoDShape, Shape);
	TwoDShape.prototype.name = '2D shape';

	function Triangle(side, height){
		this.side = side;
		this.height = height;
	}

	extendx(Triangle, TwoDShape);

	Triangle.prototype.name = 'Triangle';
	Triangle.prototype.getArea = function() {
		return this.side * this.height / 2;
	}

	console.log(new Triangle().toString());
</script>
</body>
</html>